extends Button

var load_bg = preload("res://scene/save/images/load_page_back.jpg")
var save_bg = preload("res://scene/save/images/save_page_back.jpg")
var curr_page = 1

# Called when the node enters the scene tree for the first time.
func _ready():
	Model.save = self
	var page = $pageControl
	page.connect("page_changed", self, "onPageChanged")
	pass # Replace with function body.
	
func setOnlyLoad():
	get_node("load").visible = false
	get_node("save").visible = false
	pass

func setLoadMode():
	get_node("bg").texture = load_bg
	get_node("load").visible = false
	get_node("save").visible = true
	get_node("pageControl").setTips("读取存档", curr_page, Config.save_page_max)
	$savePreview.save = false
	pass
	
func setSaveMode():
	get_node("bg").texture = save_bg
	get_node("load").visible = true
	get_node("save").visible = false
	get_node("pageControl").setTips("保存数据", curr_page, Config.save_page_max)
	$savePreview.save = true
	pass
	
func isSaveMode():
	return $savePreview.save

func _on_back_pressed():
	get_node(".").visible = false
	pass # Replace with function body.

func _on_load_pressed():
	setLoadMode()
	pass # Replace with function body.

func _on_save_pressed():
	setSaveMode()
	pass # Replace with function body.

func _on_backTitle_pressed():
	get_node(".").visible = false
	Worker.toLogo()
	pass # Replace with function body.

func _on_exitGame_pressed():
	pass # Replace with function body.
	
func onPageChanged(page):
	var savePage = $savePreview
	savePage.setPage(page)
	curr_page = page
